﻿using System;
using System.Collections.Generic;
using System.Linq;
using Pixels.Logic.Structures;
namespace Pixels.Logic.GameplayEvents
{
    class ConstructionCompleteEvent : GameplayEvent
    {

        StructureType structure;
        Tile tile;
        ConstructionSite site;

        public ConstructionCompleteEvent(ConstructionSite site) {
            this.site = site;
            this.structure = site.eventualType;
            this.tile      = site.OnTile;
            
            
        }

        internal override void execute() {
            foreach (var worker in site.AssignedColonists.ToArray()) worker.AssignedToTarget = null;
            World.Colony.destroyStructure(site);
            //site.damage(); site.damage(); // destroy site            
            var newStruct = World.Colony.spawnStructure(structure, tile.x, tile.y);

            if (structure == StructureType.antenna) World.RadarBuilt = true;

        }

        internal override string getLongDescription() {
            return GlobalConsts.getStructureConsts(structure).className + " has finished construction";
            
        }
    }
}
